home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / extras / lsperl < prev    next >
Text File  |  1996-02-25  |  1KB  |  56 lines

  1. #!/usr/local/bin/perl4.036 
  2. # Copyright Martin Leisner   leisner@sdsp.mc.xerox.com
  3. # $Id$
  4.  
  5. $directory=".";
  6. $print_directory=0;
  7. $format_string="%3s %2s %-10s%8s %s/%s\n";
  8. while(<>) {
  9.     chop;
  10.     if(length == 0) {
  11.         next;    # nothing to process
  12.     }
  13.     @line = split;
  14.     if($#line == -1 ) {
  15.         # error ? newline?
  16.         next;
  17.     }
  18.  
  19.     if($#line == 0) {
  20.         chop;
  21.         $directory = $_;
  22.         $print_directory=0;
  23.         next;
  24.     } elsif($#line == 1) {
  25.         # skip this line 
  26.         next;
  27.     } elsif(substr($_,0,1) eq "d") {
  28.     #    print "skipping directory\n";
  29.         next;
  30.     } elsif(substr($_,0,1) eq "l") {
  31.         # ignore links? 
  32.         next
  33.     }
  34.     
  35.     if($print_directory == 0) {
  36.         printf "\n%s\n", $directory;
  37.         $print_directory=1;
  38.     }
  39.  
  40.     
  41.     if($#line == 8) {
  42.         # have group?    
  43.         printf $format_string,
  44.             $line[5], $line[6], $line[7], $line[4], 
  45.                 $directory, $line[8];
  46.     } elsif($#line == 7) {
  47.         # no group
  48.         printf $format_string, $line[4], $line[5], $line[6],
  49.                 $line[3], $directory,  $line[7];
  50.     } else {
  51.         printf  "line wrong number of elements = %d\n", $#line;
  52.         die;
  53.     }
  54. }
  55.